home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / pnmmargin.z / pnmmargin
Encoding:
Text File  |  1998-10-28  |  2.0 KB  |  92 lines

  1. #!/bin/sh
  2. #
  3. # ppmmargin - add a margin to a portable anymap
  4. #
  5. # Copyright (C) 1991 by Jef Poskanzer.
  6. #
  7. # Permission to use, copy, modify, and distribute this software and its
  8. # documentation for any purpose and without fee is hereby granted, provided
  9. # that the above copyright notice appear in all copies and that both that
  10. # copyright notice and this permission notice appear in supporting
  11. # documentation.  This software is provided "as is" without express or
  12. # implied warranty.
  13.  
  14. if [ "$TMPDIR" = "" ]
  15. then
  16.         TMPDIR=/tmp
  17. fi
  18.  
  19. tmp1=$TMPDIR/pnmm1$$
  20. tmp2=$TMPDIR/pnmm2$$
  21. tmp3=$TMPDIR/pnmm3$$
  22. tmp4=$TMPDIR/pnmm4$$
  23. rm -f $tmp1 $tmp2 $tmp3 $tmp4
  24.  
  25. color="-gofigure"
  26.  
  27. # Parse args.
  28. while true ; do
  29.     case "$1" in
  30.     -w* )
  31.     color="-white"
  32.     shift
  33.     ;;
  34.     -b* )
  35.     color="-black"
  36.     shift
  37.     ;;
  38.     -c* )
  39.     shift
  40.     if [ ! ${1-""} ] ; then
  41.         echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
  42.         exit 1
  43.     fi
  44.     color="$1"
  45.     shift
  46.     ;;
  47.     -* )
  48.     echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
  49.     exit 1
  50.     ;;
  51.     * )
  52.     break
  53.     ;;
  54.     esac
  55. done
  56.  
  57. if [ ! ${1-""} ] ; then
  58.     echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
  59.     exit 1
  60. fi
  61. size="$1"
  62. shift
  63.  
  64. if [ ${2-""} ] ; then
  65.     echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
  66.     exit 1
  67. fi
  68.  
  69. # Capture input file in a tmp file, in case it's a pipe.
  70. cat $@ > $tmp1
  71.  
  72. # Construct spacer files.
  73. case "$color" in
  74.     -gofigure )
  75.     $TOOLROOT/usr/share/Insight/bin/pnmcut 0 0 1 1 $tmp1 | $TOOLROOT/usr/share/Insight/bin/pnmtile $size 1 > $tmp2
  76.     ;;
  77.     -white | -black )
  78.     $TOOLROOT/usr/share/Insight/bin/pbmmake $color $size 1 > $tmp2
  79.     ;;
  80.     * )
  81.     $TOOLROOT/usr/share/Insight/bin/ppmmake $color $size 1 > $tmp2
  82.     ;;
  83. esac
  84. $TOOLROOT/usr/share/Insight/bin/pnmflip -rotate90 $tmp2 > $tmp3
  85.  
  86. # Cat things together.
  87. $TOOLROOT/usr/share/Insight/bin/pnmcat -lr $tmp2 $tmp1 $tmp2 > $tmp4
  88. $TOOLROOT/usr/share/Insight/bin/pnmcat -tb $tmp3 $tmp4 $tmp3
  89.  
  90. # All done.
  91. rm -f $tmp1 $tmp2 $tmp3 $tmp4
  92.